using System;
using System.Collections.Generic;

namespace TTXNA.src.Engine.Vehicles
{
    public class VehicleInfo
    {
        private VehicleType vehicleType;
        string vehicleModel;
        DateTime yearInvented;
        int maxSpeed;
        int horsepower;
        Dictionary<CargoType, int> cargoes;
        List<string> meshPaths;
        decimal baseCost;
        decimal baseMaintenanceCost;
        int lifeLength;
        int modelLife;

        public VehicleInfo(VehicleType vType, string model, DateTime yearInvented, int speed, int horsepower, decimal unitCost, decimal mCost,
                            List<CargoInfo> cargoes, List<string> meshPaths, int lifeLength, int modelLife)
        {
            this.vehicleType = vType;
            this.vehicleModel = model;
            this.yearInvented = yearInvented;
            this.maxSpeed = speed;
            this.horsepower = horsepower;
            this.meshPaths = meshPaths;
            this.cargoes = new Dictionary<CargoType, int>();
            this.baseCost = unitCost;
            this.baseMaintenanceCost = mCost;
            this.lifeLength = lifeLength;
            this.modelLife = modelLife;

            foreach (CargoInfo cc in cargoes)
            {
                this.cargoes[cc.Cargo] = (int)cc.Amount;
            }

        }

        public CargoType[] CargoList
        {
            get {
                CargoType[] list = new CargoType[cargoes.Keys.Count];
                cargoes.Keys.CopyTo(list, 0);
                return list;
            }
        }

        public VehicleType VehicleType
        {
            get { return vehicleType; }
        }

        public string ModelName 
        {
            get { return vehicleModel; }
        }

        public DateTime YearInvented
        {
            get { return yearInvented; }
        }

        public int MaxSpeed
        {
            get { return maxSpeed; }
        }

        public int Horsepower
        {
            get { return maxSpeed; }
        }

        public decimal Cost
        {
            get { return baseCost; }
        }

        public int LifeLength
        {
            get { return lifeLength; }
        }

        public int ModelLife
        {
            get { return modelLife; }
        }

        public int MaxReliability
        {
            get { return DateTime.Now.Day * 3; }
        }

        public decimal MaintenanceCost
        {
            get { return baseMaintenanceCost; }
        }

        public int GetCapacityOf(CargoType type)
        {
            return cargoes[type];
        }

        public string CapacityInfo
        {
            get
            {
                string info = "";

                foreach (CargoType type in cargoes.Keys)
                {
                    info += cargoes[type] + " " + Cargo.GetQuantityAndUnit(type) + ", ";
                }
                return info.Substring(0, info.Length - 2);

            }
        }

        public string MeshPath
        {
            get { return meshPaths[0]; }
        }

        public override string ToString()
        {
            return vehicleModel;
        }

    }
}
